
public class Ball {
	
	static int nextPos = 307;
	static int ballPos = 307;
	static int oldPos = 307;
	
	static int randomDirX = 1;
	
	static double looseMovement = 0;
	
	static double ballAngle = 0.2;
	
	static int ballDir = 1;

	public static void ball(){
		if(ballDir == 1){
			
			
			if(looseMovement > 0){
				System.out.println("Moved");
				looseMovement = 0;
				randomDirX = 1;
			}else{
				
				looseMovement += ballAngle;
				
				System.out.println(looseMovement);
			}
			
			nextPos -= VarHolder.ArrayLength/VarHolder.TileWidth + randomDirX;
			if(!(VarHolder.TileType[nextPos] == 5)){
				ballDir = 2;
				VarHolder.TileType[nextPos] = 5;
			}
			oldPos = ballPos;
			ballPos -= VarHolder.ArrayLength/VarHolder.TileWidth + randomDirX;
			
		}else{
			
			if(looseMovement < 0){
				System.out.println("Moved");

				looseMovement = 0;
				randomDirX = 2;
			}else{
				looseMovement += ballAngle;
				System.out.println(looseMovement);
				
			}
			
			
			nextPos += VarHolder.ArrayLength/VarHolder.TileWidth + randomDirX;
			if(!(VarHolder.TileType[nextPos] == 5)){
				ballDir = 1;
				VarHolder.TileType[nextPos] = 5;
			}
			oldPos = ballPos;
			ballPos += VarHolder.ArrayLength/VarHolder.TileWidth + randomDirX;
			
		}
		
		
		VarHolder.Tile[oldPos] = VarHolder.Blocks[5];
		paintBall();
	}
	
	public static void paintBall(){
		VarHolder.Tile[ballPos] = VarHolder.Blocks[2];
	}

}
